package cn.kgc.springboot.controller;

import cn.kgc.springboot.entity.User;
import cn.kgc.springboot.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 课工场
 * @date 2023/11/15
 * @description
 */
@RestController
@RequestMapping("users")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping
    public List<User> getList(){

        List<User> list = userService.list();
        return list;
    }

    @GetMapping("{id}")
    public User getById(@PathVariable("id") Integer id){

        return userService.getUserById(id);
    }


    @DeleteMapping("{id}")
    public boolean removeById(@PathVariable("id") Integer id){

        return userService.removeById(id);
    }
}
